<?php
//Lay so dong tren mot danh sach
$v_num = '';
$v_dem = -1;
$v_limit_row = _CONST_NUMBER_OF_ROW_PER_LIST;
if(isset($_REQUEST['hdn_record_number_page'])){
	$v_limit_row = $_REQUEST['hdn_record_number_page'];
}
// begin--nieuvv--130608-----
$v_record_id_list="";
if(isset($_REQUEST['hdn_record_id_list'])){
	$v_record_id_list = $_REQUEST['hdn_record_id_list'];
}
if($v_record_id_list==""){
	$v_record_id_list=$_REQUEST['hdn_record_id'];
}
// the end nieuvv ---------------
//Lay trang thu x
$v_page = 1;
if(isset($_REQUEST['hdn_page'])){
	$v_page=$_REQUEST['hdn_page'];	
}
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
$v_staff_id = $_SESSION['staff_id'];
if(isset($_REQUEST['fuseaction_back'])) {
	$fuseaction_back=$_REQUEST['fuseaction_back'];
}else{
	$fuseaction_back = "";
}
$v_display_type = onegate_is_approve_leader_type($_SESSION['staff_id'], $_SESSION['onegate_current_recordtype'], $_SESSION["recordtype"]);
//echo $v_display_type;exit;
$arr_leader = get_all_leader_convert_arr($v_recordtype_filter,$_SESSION['recordtype']);

$v_display = "none";
if ($v_count_worktype > 0){
	$v_display = "block";
}
$v_file_url = trim(CONST_URL_PATH_FROM_ROOT) . $v_file_name;
$v_goto_url = "javascript:filename_onclick('T_ONEGATE_RECORD_WORK', 'PK_RECORD_WORK', 'C_FILE_NAME', 'C_FILE_CONTENT'," . strval($v_record_work_id) . ",'" . $v_file_url ."');" ;
// xac dinh label hien thi: trinh ky, duoc giai quyet, khong duoc giai quyet
$arr_result_label = onegate_get_label_of_result_type($_SESSION['recordtype'],$v_recordtype_filter);
$v_record_code_list='';

$v_update_status = true;	// DinhNQ Added 10-07-2007
for($row_index = 0;$row_index< $v_count;$row_index++){
	if ($row_index<$v_count-1)
		$v_record_code_list = $v_record_code_list.$arr_all_record[$row_index][0].", ";
	else
		$v_record_code_list = $v_record_code_list.$arr_all_record[$row_index][0];
		$v_handler_id = intval($arr_all_record[$row_index][4]);	// capture FK_HANDLER

	//---------- Update by Dinh, Nguyen ---------
	//--- Date: 10/07/2007 ----------------------
	// Content: Click lom chom ------------------
	/* Kiem tra xem co quyen cap nhat trang thai ket quan thu ly khong? */
	//echo "staff_id: ", $v_staff_id, " --- handler_id: ", $v_handler_id;
	if($v_staff_id != $v_handler_id)
		$v_update_status = false;

}

$v_recordtype_name = Get_text_from_array($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','C_NAME',$v_recordtype_filter);
//var_dump($arr_result_label);exit;
$v_work_date = date("d/m/Y");
?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">

	<?php 
	if($v_worktype_notify=='LD_PD_THUE'){ 
		$v_value=CONST_RADIO_DUYET_TB_THUE;
	?>
	<tr class="large_title">
		<td><?php echo CONST_LABEL_DUYET_TB_THUE;?></td>
	</tr>
	<?php }elseif($v_worktype_notify=='LD_PD_PHAT'){ 
		$v_value=CONST_RADIO_DUYET_TB_PHAT;
	?>
	<tr class="large_title">
		<td><?php echo CONST_LABEL_DUYET_TB_PHAT; ?></td>
	</tr>
	<?php }else{
	$v_value=CONST_RADIO_KHONG_DUYET_TB_PHAT;
	?>
	<tr class="large_title">
		<td><?php echo CONST_LABEL_DUYET_KHONG_TB_PHAT; ?></td>
	</tr>
	<?php } ?>
</table>
<!-- Bat cac phim: F12=true; Insert=false; Delete=false, ESC=true; Enter=true -->
<form action="index.php" method="post" name="f" enctype= "multipart/form-data">
<div id="hotkey" onKeyDown="javascript:process_hot_key(true,false,false,true,true);">
<!--bang chua cac text box de nhap du lieu-->

<table width="100%" class="form_table1" cellpadding="0" cellspacing="0" border="0">
		
		<input type="hidden" name="fuseaction" value="" >
		<input type="hidden" name="fuseaction_back" value="<?php echo $fuseaction_back; ?>">
		<input type="hidden" name="hdn_record_id"  value="<?php echo $v_record_id_list; ?>">
		<input type="hidden" name="hdn_fisrt" value="">
		<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
		<input type="hidden" name="hdn_work" value="">
		<input type='hidden' name='hdn_page' value='<?php echo $v_page;?>'>
		<input type='hidden' name='hdn_record_number_page' value='<?php echo $v_limit_row;?>'>
	<?php 	
	if($v_count>1){?>
	<tr>
		<td width="22%" class="normal_label"><?php echo CONST_RECORD_TYPE_LABEL; ?></td>
		<td width="78%"><?php echo $v_recordtype_name;?></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_LIST_RECORD_LABEL; ?></td>
		<td><?php echo $v_record_code_list; ?></td>
	</tr>
	<?php }else{?>
	<tr>
		<td colspan="10"><?php echo onegate_show_record_general_info($arr_single_record,$_SESSION['recordtype'],false,$p_petition_link,$p_rate_of_progress_link,$p_document_link,$p_idea_link,$p_sign_link,$p_approve_link,$p_licensing_link,$v_url_view_update_record_status); ?></td>
	</tr>
	<?php }?>
	
	<tr>
	
		<td colspan="3"><hr color="#66CCFF" width="100%" size="1"></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo _CONST_WORK_DATE_LABEL?></td>
		<td>
			<input class="normal_date_textbox" name="txt_work_date" type="text" value="<?php echo $v_work_date; ?>" optional="true" isdate="true" message="<?php echo _CONST_WORK_DATE_MESSAGE;?>" onKeyDown="change_focus(document.forms[0],this)" readonly>
		</td>
	</tr>
	
	<?php 
//----//////////////////////////////////////////////////////////////////////////////////////////////////////////
		$current_status = $arr_single_record["C_DETAIL_STATUS"];
		$p_arr_all_recordtype = $_SESSION["recordtype"];				
		if ($v_recordtype_filter !="" && $v_recordtype_filter != "All"){
			for($i=0; $i< sizeof($p_arr_all_recordtype); $i++){
				if ($p_arr_all_recordtype[$i]['PK_RECORDTYPE'] == $v_recordtype_filter ){
					$v_handle_leader_first_time_list = $p_arr_all_recordtype[$i]['FK_HANDLE_LEADER_FIRST_TIME'];
					
					//echo 'Test 145678: '.$v_handle_leader_first_time_list;
					$v_arr_handle_leader_first_time_list = explode(",", $v_handle_leader_first_time_list);
					$v_handle_leader_list = $p_arr_all_recordtype[$i]['FK_HANDLE_LEADER'];
					$v_arr_handle_leader_list = explode(",", $v_handle_leader_list);
					$v_approve_leader_list = $p_arr_all_recordtype[$i]['FK_APPROVE_LEADER_LIST'];
					$v_arr_approve_leader_list = explode(",", $v_approve_leader_list);
					//echo $i;
					//var_dump($v_handle_leader_list);exit;
					break;
				}
			}
			$sz_arr_handle_leader_first_time_list = sizeof($v_arr_handle_leader_first_time_list);
			$sz_arr_handle_leader_list = sizeof($v_arr_handle_leader_list);
			$sz_arr_approve_leader_list = sizeof($v_arr_approve_leader_list);
			$is_handle_leader_first_time = in_array($v_staff_id, $v_arr_handle_leader_first_time_list);
			//--------------------------------------------------------------------
			
			//--------------------------------------------------------------------
			$is_handle_leader = in_array($v_staff_id, $v_arr_handle_leader_list);
			//var_dump($v_arr_approve_leader_list);
			//echo '<br/>test 984551 :'.$v_staff_id;
			$is_approve_leader = in_array($v_staff_id, $v_arr_approve_leader_list);
		}		
		elseif ($v_recordtype_filter == "All") {	
			$is_approve_leader = true;
		}
//----//////////////////////////////////////////////////////////////////////////////////////////////////////////
		?>
		<tr class="normal_label" >		
			<td class="normal_label" valign="top"><?php echo CONST_LABEL_RESULT_APPROVE;?>  </td>
			<!--leav_update_begin :10/06/2008 -->
			<td ><!-- td_2_begin-->
				<table border="0" >
	 					<!-- Leav_update_begin:01/07/2008-->
							<tr class="normal_label">
								<td height="37">
								<input type="radio" name="rad_status" value="<?php echo $v_worktype_notify ?>" optional="<?php echo CONST_RECORD_STATUS_UPDATE_OPTIONAL?>" message="<?php echo CONST_RECORD_STATUS_UPDATE_MESSAGE_APPROVING?>" onclick="refuse_onclick_leav(this,document.forms[0].hdn_work)" >
								<?php echo $v_value;$v_dem++;?></td>
							</tr>
							<tr class="normal_label">
							  <td height="37"><input type="radio" name="rad_status"
							   value="<?php if($v_worktype_notify=='LD_PD_THUE'){ 
							   					echo 'LD_PHONG_TRALAI_THUE';
											}elseif($v_worktype_notify=='LD_PD_PHAT'){
												echo 'LD_PHONG_TRALAI_PHAT';
											}else{
												echo 'LD_PHONG_TRALAI_NO_PHAT';
											}?>" 
							   optional="<?php echo CONST_RECORD_STATUS_UPDATE_OPTIONAL?>" message="<?php echo CONST_RECORD_STATUS_UPDATE_MESSAGE_APPROVING?>" onclick="refuse_onclick_leav(this,document.forms[0].hdn_work)"><?php echo CONST_APPROVING_MOVE_BACK_LABEL; $v_dem++;?></td>
							</tr>
							<!-- Leav_update_end:01/07/2008-->
						</table>
	  			
						
					

	  </td><!-- td_2_end-->
	</tr>
	<tr id="tr_reason" class="normal_label" style="display:none">
		<td height="37"><?php echo CONST_RECORD_REASON_LABEL; ?></td>
		<td><textarea name="txt_reason" class="normal_textarea" value="" row="4" style="width:100%" optional="true" message=""></textarea></td>
	</tr>
</table>

<!-- Table chua cac button :cap_nhat,quay_lai-->
<table width="100%" >
	<tr>
	<td align="center" width="100%" height="40" valign="bottom">
	<?php 
				$v_url_onclick="if(test_status_update(document.forms[0].rad_status,document.forms[0].txt_reason,'".$v_num."')){save_info('UPDATE_RECORD_STATUS_NOTIFY');}";
	?>
				<input type="button" name="btn_save" class="normal_button" value="<?php  echo _CONST_SAVE_BUTTON;?>" onClick="<?php echo $v_url_onclick;?>" onKeyDown="change_focus(document.forms[0],this);" >
			
			<input type="button" name="btn_back" class="normal_button" value="<?php echo _CONST_BACK_BUTTON;?>" onClick="btn_back_onclick('<?php if($v_worktype_notify=='LD_PD_THUE'){
							echo 'DISPLAY_ALL_WATING_NOTIFY_TAX';
						}elseif($v_worktype_notify=='LD_PD_PHAT'){
							echo 'DISPLAY_ALL_WATING_NOTIFY_PUNISH';
						}else{
							echo 'DISPLAY_ALL_WATING_NO_NOTIFY_PUBNISH';
						} ?>')" onKeyDown="change_focus(document.forms[0],this)">	
	  </td>
	</tr>
</table>
</div>
</form>	